Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Conversation

@prakharg01
Copy link

Description

This pull request aims to enhance the functionality by porting the ROS1 service set_model_configuration to ROS2 (Humble). Upon launching the empty.world, users gain the ability to specify initial joint angles, facilitating entity spawning at custom configurations.

Changes Made

Ported ROS1 Service to ROS2 (Humble):

  • The primary focus of this pull request is the migration of the ROS1 service to ROS2 (Humble), ensuring compatibility with the latest ROS ecosystem advancements.
    .

How to Test

  1. Set up ROS2 (Humble) dependencies in your environment.

  2. Build and compile the project with the latest changes.

  3. Launch empty. world in your ROS2 environment.

  4. Write a service call to test the functionality:

void SetModelConfiguration::set_model_configuration()
{
  set_model_configuration_client_ =
    this->create_client<gazebo_msgs::srv::SetModelConfiguration>("/gazebo/set_model_configuration");

  if (set_model_configuration_client_->service_is_ready())
  {
    auto srv = std::make_shared<gazebo_msgs::srv::SetModelConfiguration::Request>();

    srv->model_name = std::string("<>");
    srv->urdf_param_name = std::string("robot_description");
    std::map<std::string, double> joint_map = {
      {"<>", 0.0}, {"<>", 1.56}, {"<>", -3.0},
      {"<>", 0.0}, {"<>", 1.56}, {"<>", -3.0},
      {"<>", 0.0}, {"<>", 1.56}, {"<>", -3.0},
      {"<>", 0.0}, {"<>", 1.56}, {"<>", -3.0},
    };
  for (auto & it : joint_map)
    {
      srv->joint_names.push_back(it.first);
      srv->joint_positions.push_back(it.second);
    }

    auto setmodel_future_ = set_model_configuration_client_->async_send_request(srv);
  }
  else
    RCLCPP_WARN(
      get_logger(),
      "[SetSimulationConfiguration]: not calling service using a callback, service not ready!");
}

// <> : Enter the respective arguments, this example is for a 12DOF robot.

The service is visible after launching empty.world
@prakharg01 prakharg01 changed the title Added set_model_configuration service to ROS2(Humble) gazebo_ros: Added set_model_configuration service to ROS2(Humble) Aug 21, 2023
@hushmandesmaeili
Copy link

Any updates on this?

@landersson
Copy link

I'd find this useful and would like to see this PR merged.

@graiola
Copy link

graiola commented Oct 22, 2024

no news?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants